<template>
  <div class="gk-layout-container"> 
    <div class="gk-layout-header">
  	<s-query perms="report:inert"   @click="findPage" >
  		<el-form-item>
        <el-input v-model.trim="filters.days" placeholder="天"></el-input>
        		</el-form-item>
      	</s-query>
    </div>
    <div class="gk-layout-main">
        <my-table :data="pageResult" :loading="loading"  >
            <el-table-column :label="$t('action.desc')" width="50" header-align="center" align="center">
              <template slot-scope="scope"> {{scope.$index+1}} </template>
            </el-table-column>
            <column prop="itemId" label="物料名称"     width="400"    :formatter="itemFilter"/>
            <column prop="countDb" label="数量"   />  
            <column prop="createTime" label="时间"       :formatter= "dateFormat" />  
            <column prop="id" label="单位"   :formatter="selectionFormat1"/>  
          </my-table>
      </div> 
 
   
  </div>
</template>

<script>
    import {getItemName,dictsFormat,getItem} from "@/utils/myUtil"
    import {format2,format} from "@/utils/datetime" 
    import KtButton from "@/views/Core/KtButton";  
    import MyTable from "@/views/Core/MyTable"
    import Column from "@/views/Core/Column"
    import SDict from "@/components/Kj/SDict"
    import SDictForm from "@/components/Kj/SDictForm"
    import SQuery from "@/components/Kj/SQuery" 
    import SDate from "@/components/Kj/SDate"
export default {
  components: {
        Column,
        KtButton,
        MyTable,
        SDict,
        SDictForm,
        SQuery,
        SDate
      },
  data() {
    return {
      size: "small", 
      filters: { 
        days:365
      },
      loading:false,
      pageRequest: { },
      pageResult: [],   
    };
  },
  methods: {
    // 获取分页数据
    findPage: function(data) { 
			 var d = this.filters.days
       this.$api.report.inert(d) .then(res => {
          this.pageResult = res.data;
        })
         
    }, 
    	itemFilter: function (row, column, cellValue, index) {
		 			var item=getItemName(cellValue)
					return item;
			},
 dateFormat: function (row, column, cellValue, index) {
				return format(row[column.property])
			},
 	  selectionFormat1: function (row, column, cellValue, index) {
					var i=getItem(row.itemId)

				  return dictsFormat( "units",i.u)
    },
     
  },
  mounted() { 
   
    this.findPage()
  }
};
</script>

<style scoped>
</style>